package com.wzh.glsc.search.web;

import com.wzh.glsc.search.service.MallSearchService;
import com.wzh.glsc.search.vo.SearchParam;
import com.wzh.glsc.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author xiaoming
 * @PackageName:com.wzh.glsc.product.web
 * @ClassName:@{NAME}
 * @Description:
 * @date:@{DATE}@{TIME}
 */
@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;

    @GetMapping({"/", "/index.html", "/list", "/list.html"})
    public String indexPage(SearchParam searchParam, Model model, HttpServletRequest request) {
        searchParam.set_queryString(request.getQueryString());
        SearchResult searchResult = null;
        searchResult = mallSearchService.searchEsBySearchParam(searchParam);
        model.addAttribute("result", searchResult);
        return "list";
    }

}
